package com.tianji.learning.task;


import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RequiredArgsConstructor
public class demoTask {

    @XxlJob(value = "demoJobHandler")
    public ReturnT<String> demoJobHandler(){
        log.info("XxlJob, demoJobHandler, 执行成功");
        return ReturnT.SUCCESS;
    }
    @XxlJob("shardingJobHandler")
    public ReturnT<String> shardingJobHandler(){
        int shardIndex = XxlJobHelper.getShardIndex();

        int shardTotal = XxlJobHelper.getShardTotal();
        log.info("XxlJob, shardingJobHandler, 执行成功, shardIndex: {}, shardTotal: {}", shardIndex, shardTotal);

        return ReturnT.SUCCESS;
    }

}
